let dateFn = (daytime) => {
    daytime = daytime.replace(/.000Z/g, " ");
    daytime = daytime.split("T");
    let day = daytime[0];
    let time = daytime[1].split(":");
    time = `${parseInt(time[0]) + 8}` + ":" + time[1] + ":" + time[2];
    return day + " " + time;
};

let nowDateFn = () => {
    let day = new Date().toLocaleDateString();
    day = day.replace(/\//g, "-");
    day = day.split("-");
    if (day[1] < 10) {
        day[1] = "0" + day[1];
    }
    if (day[2] < 10) {
        day[2] = "0" + day[2];
    }

    day = day.join("-");

    let time = new Date().toLocaleTimeString();
    if (time.indexOf("下午") != -1) {
        time = time.replace("下午", "").split(":");
        time[0] = String(parseInt(time[0]) + 12);
        time = time.join(":");
    } else if (time.indexOf("上午") != -1) {
        time = time.replace("上午", "").split(":");
        if (parseInt(time[0]) < 10) {
            time[0] = "0" + time[0];
        }
        time = time.join(":");
    }
    return day + " " + time;
};

export default {
    dateFn,
    nowDateFn
};